package com.guoxin.concurrentprogramming.chapter3.threadpool;

import java.util.concurrent.*;

/**
 * @author guoxin
 * @date 2019/7/16
 */
public class DivTask implements Runnable {

    private int a, b;

    public DivTask(int a, int b) {
        this.a = a;
        this.b = b;
    }

    @Override
    public void run() {
        double re = a / b;
        System.out.println(re);
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        ExecutorService service = new ThreadPoolExecutor(0, 100, 0L,
                TimeUnit.MILLISECONDS, new SynchronousQueue<>(), r -> new Thread(r,"t"));

        for(int i=0;i<5;i++){
            service.execute(new DivTask(100,i));
//            Future<?> submit = service.submit(new DivTask(100, i));
//            submit.get();
        }
    }
}
